<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 
        100 内的整数求和
            1 + 2 + 3 + 4 + 5 + 。。。 + 100
            sum = 1 + 2
            sum + 3
            sum + 4 ...
            1. 遍历 1 - 100
            2. 声明一个变量保存求和
            3. 累加
         */
         let sum = null;
        for (let i = 0; i <= 100; i++) {
            console.log(i);
            sum = sum + i;
        }
        console.log(sum); 

      /*   let sum = null;
        for (let i = 100; i > 0; i--) {
            console.log(i);
            sum = sum + i;
        }
        console.log(sum); */

    </script>
</body>
</html>